<template>
	<view class="content">
		<view class="serve-list">
			<view class="serve-item" v-for="item in serviceList" key="index" @click="navigateTo"
				:data-url="'/subPages/serveDetail/serveDetail?id='+item.id">  
				<image class="item-img" :src="item.banner_image" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: '',
				serviceList: [],
			}
		},
		onLoad(query) {
			console.log(query);
			this.type = query.type;
		},
		onShow() {
			this.getserviceList();
		},
		methods: {

			async getserviceList() {
				let _this = this;
				let res = await this.$api.serviceList({
					type: this.type
				});

				if (res.code == 1) {
					_this.serviceList = res.data;
				}
			},

			// 跳转函数
			navigateTo(e) {
				console.log(e.currentTarget.dataset.url);
				wx.navigateTo({
					url: e.currentTarget.dataset.url,
				})
			},

		}
	}
</script>

<style>
	.serve-list {
		padding: 20rpx;
	}

	.serve-item {
		font-size: 24rpx;
		margin-bottom: 20rpx;
	}

	.item-img {
		width: 100%;
	}
</style>